package com.njsf.controller.back;

import com.github.pagehelper.PageInfo;
import com.njsf.dto.ResponseJson;
import com.njsf.pojo.Book;
import com.njsf.pojo.Order;
import com.njsf.pojo.OrderListLevel1;
import com.njsf.pojo.OrderListLevel2;
import com.njsf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@Controller
@RequestMapping("/back")
public class OrderController {

    @Autowired
    OrderService orderService;

    @RequestMapping("/orderlistview")
    public String orderList(@RequestParam(required = false,defaultValue = "1") Integer start,
                           @RequestParam(required = false,defaultValue = "5") Integer pageSize,
                           Map<String,Object> map){
        PageInfo<OrderListLevel1> pageInfo = orderService.getOrders(start, pageSize);
        map.put("pageInfo",pageInfo);
        return "back/order/order-list";
    }

    @RequestMapping("/orderlist2view")
    public String orderList2(@RequestParam(required = false,defaultValue = "1") Integer start,
                             @RequestParam(required = false,defaultValue = "5") Integer pageSize,
                             Map<String,Object> map,Integer id){
        PageInfo<OrderListLevel2> pageInfo = orderService.getOneUserOrders(start, pageSize,id);
        map.put("pageInfo",pageInfo);
        map.put("id",id);

        return "back/order/order-list-2";
    }
}
